//
//  CSSetViewController.m
//  CreateWithSuper
//
//  Created by chenjunbo on 2024/7/3.
//  Copyright © 2024 CS. All rights reserved.
//

#import "CSSetViewController.h"
#import <MessageUI/MessageUI.h>

@interface CSSetViewController ()<MFMailComposeViewControllerDelegate>

@end

@implementation CSSetViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (IBAction)backClick:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)contact:(id)sender {
    if (![MFMailComposeViewController canSendMail]) {
        UIAlertController *alert = [UIAlertController
                                    alertControllerWithTitle:@"Set an email account"
                                    message:@"Enter system mail settings?"
                                    preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *defaultAction = [UIAlertAction
                                        actionWithTitle:@"OK"
                                        style:UIAlertActionStyleDefault
                                        handler:^(UIAlertAction * _Nonnull action) {
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"message:"] options:@{} completionHandler:^(BOOL success) {
                
            }];
        }];
        
        UIAlertAction *cancleAction = [UIAlertAction
                                        actionWithTitle:@"Cancel"
                                        style:UIAlertActionStyleDefault
                                        handler:^(UIAlertAction * _Nonnull action) {
            
        }];
        
        [alert addAction:defaultAction];
        [alert addAction:cancleAction];
        
        [self presentViewController:alert animated:YES completion:nil];
    } else {
        MFMailComposeViewController *_composer = [[MFMailComposeViewController alloc] init];
        _composer.mailComposeDelegate = self;
        NSArray *array = @[@"lindamia403@gmail.com"];
        if (array.count) {
            [_composer setToRecipients:array];
        }
        [_composer setSubject:@"Unlimited Painting"];

        [self presentViewController:_composer animated:YES completion:nil];
    }
}

- (IBAction)share:(id)sender {
    NSString *shareText = @"Unlimited Painting";
    NSURL *shareURL = [NSURL URLWithString:@"https://apps.apple.com/us/app/6511221004"];
    NSArray *itemsToShare = @[shareText, shareURL];
    UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
    activityVC.excludedActivityTypes = @[UIActivityTypePostToFacebook,
                                             UIActivityTypePostToTwitter,
                                             UIActivityTypePostToWeibo,
                                             UIActivityTypeMessage,
                                             UIActivityTypeMail,
                                             UIActivityTypeCopyToPasteboard,
                                             UIActivityTypeAssignToContact,
                                             UIActivityTypePostToTencentWeibo,
                                             UIActivityTypeAirDrop];
    [self presentViewController:activityVC animated:YES completion:nil];
}

- (IBAction)about:(id)sender {
    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://qrscanonetool.com/server.html"]];
}

- (IBAction)pp:(id)sender {
    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"http://qrscanonetool.com/Privacy%20Policy.html"]];
}

- (IBAction)user:(id)sender {
    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"https://sites.google.com/view/vpn-privacy-policyhealth/home"]];
}
 
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
